package com.share.config;

import com.share.interceptor.CaptchaInterceptor;
import com.share.interceptor.LogInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private CaptchaInterceptor captchaInterceptor;

    @Autowired
    private LogInterceptor logInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 将拦截器应用到/user/getCaptcha路径
//        registry.addInterceptor(captchaInterceptor).addPathPatterns("/user/getCaptcha");
        registry.addInterceptor(logInterceptor).addPathPatterns("/**");
    }
}